home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Freeware 2002 November
/
SGI Freeware 2002 November - Disc 2.iso
/
dist
/
fw_groff.idb
/
usr
/
freeware
/
info
/
groff-5.z
/
groff-5
Wrap
Text File
|
2002-04-08
|
51KB
|
1,668 lines
This is groff, produced by makeinfo version 4.0 from groff.texinfo.
INFO-DIR-SECTION Miscellaneous
START-INFO-DIR-ENTRY
* Groff: (groff). The GNU troff document formatting system.
END-INFO-DIR-ENTRY
This Info file documents GNU troff version 1.16.
Published by the Free Software Foundation 59 Temple Place, Suite 330
Boston, MA 02111-1307 USA
Copyright (C) 1994-2000 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that this permission notice may be stated in a
translation approved by the Foundation.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided also
that the section entitled "GNU General Public License" is included
exactly as in the original, and provided that the entire resulting
derived work is distributed under the terms of a permission notice
identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that the section entitled "GNU General Public License"
may be included in a translation approved by the Free Software
Foundation instead of in the original English.
File: groff, Node: Writing Macros, Next: Page Motions, Prev: Conditionals and Loops, Up: gtroff Reference
Writing Macros
==============
A "macro" is a collection of text and embedded commands which can be
invoked multiple times. Use macros to define common operations.
- Request: .de name [end]
Define a new macro named NAME. `gtroff' copies subsequent lines
(starting with the next one) into an internal buffer until it
encounters the line `..' (two dots). The optional second argument
to `de' changes this to a macro to `.END'.
Note that no leading whitespace is allowed in the line containing
the ending token (either `..' or the macro `.END').
Here a small example macro called `P' which causes a break and
inserts some vertical space. It could be used to separate
paragraphs.
.de P
. br
. sp .8v
..
- Request: .am xx
Works similarly to `de' except it appends onto the macro named XX.
So, to make the previously defined `P' macro actually do indented
instead of block paragraphs, add the necessary code to the
existing macro like this:
.am P
.ti +5n
..
- Request: .als new old
Create an alias named NEW for the request, string, macro, or
diversion object named OLD. The new name and the old name are
exactly equivalent (it is similar to a hard rather than a soft
link). If OLD is undefined, `gtroff' generates a warning of type
`mac' and ignores the request.
The `de', `am', `di', `da', `ds', and `as' requests only create a
new object if the name of the macro, diversion or string diversion
is currently undefined or if it is defined to be a request;
normally they modify the value of an existing object.
* Menu:
* Copy-in Mode::
* Parameters::
File: groff, Node: Copy-in Mode, Next: Parameters, Prev: Writing Macros, Up: Writing Macros
Copy-in Mode
------------
When `gtroff' reads in the text for a macro or diversion, it copies
the text (including request lines, but excluding escapes) into an
internal buffer. Escapes are converted into an internal form, except
for `\n', `\$', `\*', `\\' and `\<RET>' which are evaluated and
inserted into the text where the escape was located. This is known as
"copy-in" mode or "copy" mode.
What this means is that you can specify when these escapes are to be
evaluated (either at copy-in time or at the time of use) by insulating
the escapes with an extra backslash. Compare this to the `\def' and
`\edef' commands in TeX.
The following example prints the numbers 20 and 10:
.nr x 20
.de y
.nr x 10
\&\nx
\&\\nx
..
.y
File: groff, Node: Parameters, Prev: Copy-in Mode, Up: Writing Macros
Parameters
----------
The arguments to a macro can be examined using a variety of escapes.
The number of arguments is available in the `.$' number register. Any
individual argument can be retrieved with one of the following escapes:
- Escape: \$n
- Escape: \$(NN
- Escape: \$[NNN]
The escapes `\$N', `\$(NN' and `\$[NNN]' retrieve the Nth, NNth or
NNNth argument. As usual, the first form only accepts a single
number (larger than zero), the second a two-digit number (larger
or equal to 10), and the third any positive integer value (larger
than zero). Macros can have an unlimited number of arguments.
Note that due to copy-in mode, use two backslashes on these in
actual use to prevent interpolation until the macro is actually
invoked.
- Request: .shift [n]
Shifts the arguments 1 position, or as many positions as specified
by its argument. After executing this request, argument I becomes
argument I-N; arguments 1 to N are no longer available. Shifting
by negative amounts is currently undefined.
- Escape: \$*
- Escape: \$@
In some cases it is convenient to use all of the arguments at once
(for example, to pass the arguments along to another macro). The
`\$*' escape concatenates all the arguments separated by spaces. A
similar escape is `\$@', which concatenates all the arguments with
each surrounded by double quotes, and separated by spaces.
- Escape: \$0
The name used to invoke the current macro. The `als' request can
make a macro have more than one name.
.de vl
.ie \\n(.$=1 .ds Vl Pre-Release Version
.el .ds Vl Version \\$3, \\$4.
..
This would be called as
.vl $Id: groff.texinfo,v 1.77 2001/05/07 13:36:24 wlemb Exp $
*Note Request Arguments::.
File: groff, Node: Page Motions, Next: Drawing Requests, Prev: Writing Macros, Up: gtroff Reference
Page Motions
============
- Request: .sp [len]
Motions up and down the page can be done with the `sp' request.
However, this causes a break so that the actual effect is to move
to the left margin and then to the specified location.
- Request: .mk [reg]
- Request: .rt reg
The request `mk' can be used to mark a location on a page, for
movement to later. This request takes a register name as an
argument in which to store the current page location. With no
argument it stores the location in an internal register. The
results of this can be used later by the `rt' or the `sp' request.
The `rt' request returns _upwards_ to the location given in the
register name given as an argument; with no argument it returns to
the location marked with the `mk' request.
The following escapes give fine control of movements about the page.
- Escape: \v'E'
The `\v'E'' escape enables arbitrary vertical motion from the
current location on the page. The argument E specifies the
distance to move; positive is downwards and negative upwards. The
default unit for this escape `v'. Beware, however, that `gtroff'
continues text processing at the point where the motion ends, so
you should always balance motions to avoid interference with text
processing.
There are some special case escapes for vertical motion.
`\r'
move upwards 1v.
`\u'
move upwards .5v.
`\d'
move down .5v.
- Escape: \h'E'
The `\h'E'' escape provides horizontal motions. The expression E
indicates how far to move: positive is rightwards and negative
leftwards.
There are a number of special case escapes for horizontal motion:
`\<SP>'
An unbreakable and unpaddable (i.e. not expanded during filling)
space. (Note: This is a backslash followed by a space.)
`\~'
An unbreakable space that stretches like a normal inter-word space
when a line is adjusted.
`\|'
A 1/6th em space. Ignored for tty output devices (rounded to
zero).
`\^'
A 1/12th em space. Ignored for tty output devices (rounded to
zero).
`\0'
A space the size of a digit.
`\&'
A zero width space.
`\)'
Like `\&' except that it behaves like a character declared with the
`cflags' request to be transparent for the purposes of end of
sentence recognition.
The following string sets the TeX logo:
.ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
- Escape: \w'TEXT'
Used as `\w'TEXT'', returns the width of the specified TEXT in
basic units. This allows horizontal movement based on the width
of some arbitrary text (e.g. given as an argument to a macro).
Font changes may occur in TEXT which don't affect current settings.
After use, `\w' sets several registers:
`st'
`sb'
The highest and lowest point, respectively, in TEXT.
`rst'
`rsb'
Like the `st' and `sb' registers, but takes account of the
heights and depths of characters.
`ct'
Defines the kinds of characters occurring in TEXT:
0
only short characters, no descenders or tall characters.
1
at least one descender.
2
at least one tall character.
3
at least one each of a descender and a tall character.
`ssc'
The amount of horizontal space (possibly negative) that
should be added to the last character before a subscript.
`skw'
How far to right of the center of the last character in the
`\w' argument, the center of an accent from a roman font
should be placed over that character.
- Escape: \k'X'
Stores the current horizontal position in register X. Use this,
for example, to return to the beginning of a string for
highlighting or other decoration.
- Register: \n[.k]
A read-only number register containing the current horizontal
output position.
File: groff, Node: Drawing Requests, Next: Traps, Prev: Page Motions, Up: gtroff Reference
Drawing Requests
================
`gtroff' provides a number of ways to draw lines and other figures
on the page. Used in combination with the page motion commands (see
*Note Page Motions::, for more info), a wide variety of figures can be
drawn. However, for complex drawings these operations can be quite
cumbersome, and it may be wise to use graphic preprocessors like `gpic'
or `ggrn'. *Note gpic::, and *Note ggrn::, for more information.
All drawing is done via escapes.
- Escape: \l'L C'
Draws a line rightwards from the current location. The full
syntax for this escape is:
\l'LC'
where L is the length of the line to be drawn, starting at the
current location; positive numbers draw to the right, and negative
numbers draw towards the left. This can also be specified
absolutely (i.e. with a leading `|') which draws back to the
beginning of the line.
The optional second parameter C is a character to draw the line
with. If this second argument is not specified, `gtroff' uses the
underscore character.
To separate the two arguments (to prevent `gtroff' from
interpreting a drawing character as a scaling indicator) use `\&'.
Here a small useful example:
.de box
\(br\\$*\(br\l'|0\(rn'\l'|0\(ul'
..
Note that this works by outputting a box rule (a vertical line),
then the text given as an argument and then another box rule.
Then the line drawing escapes both draw from the current location
to the beginning of the _input_ line.
- Escape: \L'L C'
Draws vertical lines. Its parameters are similar to the `\l'
escape. The movement is downwards for positive values, and
upwards for negative values. The default character is the box
rule character. As with the vertical motion escapes, text
processing blindly continues where the line ends.
- Escape: \D'COMMAND ARG ...'
The `\D' escape provides a variety of drawing functions. While
the previous escapes work on a character device, these escapes do
not.
`\D'l DX DY''
Draw a line from the current location to the relative point
specified by (DX,DY).
`\D'c D''
Draw a circle with a diameter of D with the leftmost point at
the current position.
`\D'C D''
Draw a solid circle with the same parameters as an outlined
circle.
`\D'e DX DY''
Draw an ellipse with a horizontal diameter of DX and a
vertical diameter of DY with the leftmost point at the
current position.
`\D'E DX DY''
Draw a solid ellipse with the same parameters as an outlined
ellipse.
`\D'a DX1 DY1 DX2 DY2''
Draw an arc clockwise from the current location through the
two specified locations (DX1,DY1) and (DX2,DY2).
`\D'~ DX1 DY1 DX2 DY2 ...''
Draw a spline from the current location to (DX1,DY1) and then
to (DX2,DY2), and so on.
`\D'f N''
Set the shade of gray to be used for filling solid objects
to N; N must be an integer between 0 and 1000, where 0
corresponds solid white and 1000 to solid black, and values
in between correspond to intermediate shades of gray. This
applies only to solid circles, solid ellipses and solid
polygons. By default, a level of 1000 is used.
`\D'p DX1 DY1 DX2 DY2 ...''
Draw a polygon from the current location to (DX1,DY1) and
then to (DX2,DY2) and so on. When the specified data points
are exhausted, a line is drawn back to the starting point.
`\D'P DX1 DY1 DX2 DY2 ...''
Draw a solid polygon with the same parameters as an outlined
polygon.
`\D't N''
Set the current line thickness to N machine units. A value of
zero selects the smallest available line thickness. A
negative value makes the line thickness proportional to the
current point size (this is the default behaviour of
`ditroff').
- Escape: \b'STRING'
"Piles" a sequence of characters vertically, and centers it
vertically on the current line. Use it to build large brackets
and braces.
\b'\(lt\(bv\(lk\(bv\(lb'
*Note Drawing Functions::.
File: groff, Node: Traps, Next: Diversions, Prev: Drawing Requests, Up: gtroff Reference
Traps
=====
"Traps" are locations, which, when reached, call a specified macro.
These traps can occur at a given location on the page, at a given
location in the current diversion, after a certain number of input
lines or at the end of input.
* Menu:
* Page Location Traps::
* Diversion Traps::
* Input Line Traps::
* End-of-input Traps::
File: groff, Node: Page Location Traps, Next: Diversion Traps, Prev: Traps, Up: Traps
Page Location Traps
-------------------
"Page location traps" perform an action when `gtroff' reaches a
certain vertical location on the page. Page location traps have a
variety of purposes, including:
* setting headers and footers
* setting body text in multiple columns
* setting footnotes
- Request: .vpt flag
- Register: \n[.vpt]
Enables vertical position traps if FLAG is non-zero, or disables
them otherwise. Vertical position traps are traps set by the `wh'
or `dt' requests. Traps set by the `it' request are not vertical
position traps. The parameter that controls whether vertical
position traps are enabled is global. Initially vertical position
traps are enabled. The current setting of this is available in the
`.vpt' read-only number register.
- Request: .wh dist macro
Sets a page location trap. Positive values for DIST set the trap
relative to the top of the page; negative values set the trap
relative to the bottom of the page.
MACRO is the name of the macro to execute when the trap is sprung.
The following is a simple example of how many macro packages set
headers and footers.
.de hd \" Page header
'sp .5i
.tl 'Title''date'
'sp .3i
..
.de fo \" Page footer
'sp 1v
.tl ''%''
'bp
..
.wh 0 hd \" trap at top of the page
.wh -1i fo \" trap one inch from bottom
- Register: \n[.t]
A read-only number register holding the distance to the next trap.
- Request: .ch dist macro
Changes the location of a trap. The first argument is the name of
the macro to be invoked at the trap, and the second argument is
the new location for the trap (note that the parameters are
specified the opposite of the `.wh' request). This is useful for
building up footnotes in a diversion to allow more space at the
bottom of the page for them.
- Register: \n[.ne]
The read-only number register `.ne' contains the amount of space
that was needed in the last `ne' request that caused a trap to be
sprung. Useful in conjunction with the `.trunc' register. *Note
Page Control::, for more information.
- Register: \n[.trunc]
A read-only register containing the amount of vertical space
truncated by the most recently sprung vertical position trap, or,
if the trap was sprung by an `ne' request, minus the amount of
vertical motion produced by the `ne' request. In other words, at
the point a trap is sprung, it represents the difference of what
the vertical position would have been but for the trap, and what
the vertical position actually is.
File: groff, Node: Diversion Traps, Next: Input Line Traps, Prev: Page Location Traps, Up: Traps
Diversion Traps
---------------
- Request: .dt dist macro
Sets a trap _within_ a diversion. DIST is the first argument is
the location of the trap (identical to the `.wh' request) and
MACRO is the name of the macro to be invoked. The number register
`.t' still works within diversions. *Note Diversions::, for more
information.
File: groff, Node: Input Line Traps, Next: End-of-input Traps, Prev: Diversion Traps, Up: Traps
Input Line Traps
----------------
- Request: .it n macro
Sets an input line trap. N is the number of lines of input which
may be read before "springing" the trap, MACRO is the macro to be
invoked. Request lines are not counted as input lines.
For example, one possible use is to have a macro which prints the
next N lines in a bold font.
.de B
.it \\$1 B-end
.ft B
..
.de B-end
.ft R
..
File: groff, Node: End-of-input Traps, Prev: Input Line Traps, Up: Traps
End-of-input Traps
------------------
- Request: .em macro
Sets a trap at the end of input. The MACRO specified is executed
after the last line of the input file has been processed.
For example, if the document had to have a section at the bottom
of the last page for someone to approve it, the `em' request could
be used.
.de approval
.ne 5v
.sp |(\\n(.t-6v)
.in +4i
.lc _
.br
Approved:\t\a
.sp
Date:\t\t\a
..
.em approval
File: groff, Node: Diversions, Next: Environments, Prev: Traps, Up: gtroff Reference
Diversions
==========
In `gtroff' it is possible to "divert" text into a named storage
area. Due to the similarity to defining macros it is sometimes said to
be stored in a macro. This is used for saving text for output at a
later time, which is useful for keeping blocks of text on the same
page, footnotes, tables of contents and indices.
- Request: .di macro
- Request: .da macro
Begins a diversion. Like the `de' request, it takes an argument
of a macro name to divert subsequent text into. The `da' macro
appends to an existing diversion.
`di' or `da' without an argument ends the diversion.
- Register: \n[.z]
- Register: \n[.d]
Diversions may be nested. The read-only number register `.z'
contains the name of the current diversion (this is a string-valued
register). The read-only number register `.d' contains the current
vertical place in the diversion. If not in a diversion it is the
same as the register `nl'.
- Register: \n[.h]
The "high-water mark" on the current page. It corresponds to the
text baseline of the lowest line on the page. This is a read-only
register.
- Register: \n[dn]
- Register: \n[dl]
After completing a diversion, the read-write number registers `dn'
and `dl' contain the vertical and horizontal size of the diversion.
.\" Center text both horizontally & vertically
.de (c
.br
.nf
.di @c
..
.de )c
.br
.di
.nr @s (((\\n(.tu-\\n(dnu)/2u)-1v)
.sp \\n(@su
.ce 1000
.nf
..br
.ce 0
.sp \\n(@su
.br
.fi
.rr @s
..
- Escape: \!
- Escape: \?ANYTHING\?
Prevents requests, macros and escapes from being interpreted when
read into a diversion. This takes the given text and
"transparently" embeds it into the diversion. This is useful for
macros which shouldn't be invoked until the diverted text is
actually output.
The `\!' escape transparently embeds text up to and including the
end of the line. The `\?' escape transparently embeds text until
the next occurrence of the `\?' escape. For example:
\?ANYTHING\?
ANYTHING may not contain newlines; use `\!' to embed newlines in
a diversion. The escape sequence `\?' is also recognized in copy
mode and turned into a single internal code; it is this code that
terminates anything. Thus the following example prints 4.
.nr x 1
.nf
.di d
\?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
.di
.nr x 2
.di e
.d
.di
.nr x 3
.di f
.e
.di
.nr x 4
.f
- Request: .asciify div
"Unformats" the diversion specified by DIV in such a way that
ASCII and space characters that were formatted and diverted are
treated like ordinary input characters when the diversion is
reread. It can be also used for gross hacks; for example, the
following sets register `n' to 1.
.tr @.
.di x
@nr n 1
.br
.di
.tr @@
.asciify x
.x
*Note Copy-in Mode::.
File: groff, Node: Environments, Next: Suppressing output, Prev: Diversions, Up: gtroff Reference
Environments
============
It happens frequently that some text should be printed in a certain
format regardless of what may be in effect at the time, for example, in
a trap invoked macro to print headers and footers. To solve this
`gtroff' processes text in "environments". An environment contains
most of the parameters that control text processing. It is possible to
switch amongst these environments; by default `gtroff' processes text
in environment 0. The following is the information kept in an
environment.
* font parameters (size, family, style, character height and slant,
space and sentence space size)
* page parameters (line length, title length, vertical spacing, line
spacing, indentation, line numbering, hyphenation data)
* fill and adjust mode
* tab stops, tab and leader characters, escape character, no-break
and hyphen indicators, margin character data
* partially collected lines
These environments may be given arbitrary names (see *Note
Identifiers::, for more info). Old versions of `troff' only had
environments named `0', `1' and `2'.
- Request: .ev env
- Register: \n[.ev]
Switches to another environment. The argument ENV is the name of
the environment to switch to. With no argument, `gtroff' switches
back to the previous environment. There is no limit on the number
of named environments; they are created the first time that they
are referenced. The `.ev' read-only register contains the name or
number of the current environment. This is a string-valued
register.
Note that a call to `ev' (with argument) pushes the previously
active environment onto a stack. If, say, environments `foo',
`bar', and `zap' are called (in that order), the first `ev'
request without parameter switches back to environment `bar'
(which is popped off the stack), and a second call switches back
to environment `foo'.
Here is an example:
.ev footnote-env
.fam N
.ps 6
.vs 8
.ll -.5i
.ev
...
.ev footnote-env
\(dg Note the large, friendly letters.
.ev
- Request: .evc env
Copies the environment ENV into the current environment.
File: groff, Node: Suppressing output, Next: I/O, Prev: Environments, Up: gtroff Reference
Suppressing output
==================
- Escape: \ONUM
Disables or enables output depending on the value of NUM:
`\O0'
Disable any ditroff glyphs from being emitted to the device
driver.
`\O1'
Enable output of glyphs.
`\O0' and `\O1' also reset the four registers `opminx', `opminy',
`opmaxx', and `opmaxy' to -1. *Note Register Index::. These four
registers mark the top left and bottom right hand corners of a box
which encompasses all written glyphs.
The following two forms of `\O' are specific to `grohtml'.
`\O2'
Disable any ditroff glyphs from being emitted to the device
driver. Also write out to `stderr' the page number and four
registers encompassing the glyphs previously written since
the last call to `\O'.
`\O3'
Enable output of glyphs (the default). Also write out to
`stderr' the page number and four registers encompassing the
glyphs previously written since the last call to `\O'.
File: groff, Node: I/O, Next: Postprocessor Access, Prev: Suppressing output, Up: gtroff Reference
I/O
===
`gtroff' has several requests for including files:
- Request: .so file
Reads in the specified FILE and includes it in place of the `so'
request. This is quite useful for large documents, e.g. keeping
each chapter in a separate file. *Note gsoelim::, for more
information.
- Request: .mso file
Identical to the `so' request except that `gtroff' searches for
the specified FILE in the same directories as macro files for the
the `-m' command line option. If the file name to be included has
the form `NAME.tmac' and it isn't found, `mso' tries to include
`tmac.NAME' and vice versa.
- Request: .cf file
- Request: .trf file
Transparently outputs the contents of FILE. Each line is output
as it were preceded by `\!'; however, the lines are not subject to
copy mode interpretation. If the file does not end with a
newline, then a newline is added. For example, to define a
macro `x' containing the contents of file `f', use
.di x
.trf f
.di
The request `.cf FILENAME', when used in a diversion, embeds an
object in the diversion which, when reread, causes the contents of
FILENAME to be transparently copied through to the output.
In UNIX `troff', the contents of FILENAME is immediately copied
through to the output regardless of whether there is a current
diversion; this behaviour is so anomalous that it must be
considered a bug. This request causes a line break.
With `trf', unlike `cf', the file cannot contain characters such
as NUL that are not valid `gtroff' input characters (*note
Identifiers::). This request causes a line break.
- Request: .nx
Forces `gtroff' to continue processing of the file specified as an
argument.
- Request: .rd
The `rd' request reads from standard input, and includes what is
read as though it were part of the input file. Text is read until
a blank line is encountered.
Using the `nx' and `rd' requests, it is easy to set up form letters.
The form letter template is constructed like this:
.ce
\*(td
.sp 2
.nf
.rd
.sp
.rd
.fi
Body of letter.
.bp
.nx repeat.let
When this is run, the following file should be redirected in. Note that
requests included in this file are executed as though they were part of
the form letter. The last block of input is the `ex' requests which
tells groff to stop processing. If this was not there, groff would not
know when to stop.
Trent A. Fisher
708 NW 19th Av., #202
Portland, OR 97209
Dear Trent,
Len Adollar
4315 Sierra Vista
San Diego, CA 92103
Dear Mr. Adollar,
.ex
- Request: .pi pipe
Pipes the output of `gtroff' to the shell command(s) specified by
PIPE. This request must occur before `gtroff' has a chance to
print anything.
- Request: .sy cmds
- Register: \n[systat]
In "unsafe" mode, executes the shell command(s) specified by CMDS.
The output is not saved anyplace, so it is up to the user to do
so.
For example, the following example introduces the current time
into a document:
.sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
(localtime(time))[2,1,0]' > /tmp/x\n[$$]
.so /tmp/x\n[$$]
.sy rm /tmp/x\n[$$]
\nH:\nM:\nS
Note that this works by having the `perl' script (run by `sy')
print out the `nr' requests which set the number registers `H',
`M' and `S', and then reads those commands in with the `so'
request.
The `systat' read-write number register contains the return value
of the `system()' function executed by the last `sy' request.
- Request: .open stream file
- Request: .opena stream file
Opens the specified FILE for writing and associates the specified
STREAM with it.
The `opena' is like `open', but if the file exists, append to it
instead of truncating it.
- Request: .write stream data
Writes to the file associated with the specified STREAM. The
stream must previously have been the subject of an open request.
The remainder of the line is interpreted as the `ds' request reads
its second argument: A leading `"' is stripped, and it is read in
copy-in mode.
- Request: .close stream
Closes the specified STREAM; the stream is no longer an acceptable
argument to the `write' request.
- Escape: \V'XXX'
Interpolates the contents of the specified environment variable,
as returned by the function `getenv'. Specify the argument to
`\V' as an identifier, i.e. `\VX', `\V(XX' or `\V[XXX]'. `\V' is
interpreted in copy-in mode.
File: groff, Node: Postprocessor Access, Next: Miscellaneous, Prev: I/O, Up: gtroff Reference
Postprocessor Access
====================
There are two escapes which give information directly to the
postprocessor. This is particularly useful for embedding POSTSCRIPT
into the final document.
- Escape: \X'XXX'
Embeds its argument into the `gtroff' output preceded with `x X'.
- Escape: \Y'XXX'
The `\Y' escape is called with an identifier (i.e. `\YX', `\Y(XX'
or `\Y[XXX]'). This is approximately equivalent to `\X'\*[XXX]''.
However, the contents of the string or macro XXX are not
interpreted; also it is permitted for XXX to have been defined as
a macro and thus contain newlines (it is not permitted for the
argument to `\X' to contain newlines). The inclusion of newlines
requires an extension to the UNIX `troff' output format, and
confuses drivers that do not know about this extension.
*Note Output Devices::.
File: groff, Node: Miscellaneous, Next: Gtroff Internals, Prev: Postprocessor Access, Up: gtroff Reference
Miscellaneous
=============
This section documents parts of `gtroff' which cannot (yet) be
categorized elsewhere in this manual.
- Request: .nm start inc space indent
Prints line numbers in the left margin. START is the line number
of the _next_ output line; this defaults to 1. INC indicates on
which lines numbers are printed, i.e. 5 means put line numbers on
every 5 lines; this defaults to 1. SPACE is the space to be left
between the number and the text; this defaults to 1. The fourth
argument is the indentation of the line numbers. Without
arguments, line numbers are turned off.
- Request: .nn [skip]
Temporarily turns off line numbering. The argument is the number
of lines not to be numbered; this defaults to 1.
- Request: .mc char dist
Prints margin characters to the right of the text. The first
argument is the character to be printed, and the second argument
is the distance away from the main body text. With no arguments
the margin characters are turned off. If this occurs before a
break, no margin character is printed.
This is quite useful for indicating text that has changed, and, in
fact, there are programs available for doing this (they are called
`nrchbar' and `changebar' and can be found in any
`comp.sources.unix' archive.
- Request: .lf line filename
A debugging aid for documents which are split into many files,
then put together with `soelim' and other preprocessors. The
second argument is the name of the file and the first argument is
the input line number in that file. This way `gtroff' can produce
error messages which are intelligible to the user.
File: groff, Node: Gtroff Internals, Next: Debugging, Prev: Miscellaneous, Up: gtroff Reference
`gtroff' Internals
==================
`gtroff' processes input in three steps. One or more input
characters are converted to an "input token". Then, one or more input
tokens are converted to an "output node". Finally, output nodes are
converted to the intermediate output language understood by all output
devices.
For example, the input string `fi\[:u]' is converted in a character
token `f', a character token `i', and a special token `:u'
(representing u umlaut). Later on, the character tokens `f' and `i'
are merged to a single output node representing the ligature glyph
`fi'; the same happens with `:u'. All output glyph nodes are
`processed' which means that they are invariably associated with a
given font, font size, advance width, etc. During the formatting
process, `gtroff' itself adds various nodes to control the data flow.
Macros, diversions, and strings collect elements in two chained
lists: a list of input tokens which have been passed unprocessed, and a
list of output nodes. Consider the following the diversion.
.di xxx
a
\!b
c
.br
.di
It contains these elements.
node list token list element number
line start node -- 1
glyph node `a' -- 2
word space node -- 3
-- `b' 4
-- `\n' 5
glyph node `c' -- 6
vertical size node -- 7
vertical size node -- 8
-- `\n' 9
Elements 1, 7, and 8 are inserted by `gtroff'; the latter two (which
are always present) specify the vertical extent of the last line,
possibly modified by `\v'. The `br' request finishes the current
partial line, inserting a newline input token which is subsequently
converted to a space when the diversion is reread. Note that the word
space node has a fixed width which isn't stretchable anymore. To
convert horizontal space nodes back to input tokens, use the `unformat'
request.
Macros only contain elements in the token list (and the node list is
empty); diversions and strings can contain elements in both lists.
File: groff, Node: Debugging, Next: Implementation Differences, Prev: Gtroff Internals, Up: gtroff Reference
Debugging
=========
`gtroff' is not easy to debug, but there are some useful features
and strategies for debugging.
- Request: .tm string
Sends the STRING to the standard error stream; this is very useful
for printing debugging output among other things.
- Request: .ab [string]
Similar to the `tm' request, except that it causes `gtroff' to
stop processing. With no argument it prints `User Abort'.
- Request: .ex
The `ex' request also causes `gtroff' to stop processing if
encountered at the topmost level; see also *Note I/O::.
When doing something involved it is useful to leave the debugging
statements in the code and have them turned on by a command line flag.
.if \n(DB .tm debugging output
To activate these statements say
groff -rDB=1 file
If it is known in advance that there will be many errors and no
useful output, `gtroff' can be forced to suppress formatted output with
the `-z' flag.
- Request: .pm
The `pm' request prints out the entire symbol table on `stderr'.
- Request: .pnr
Prints the names and contents of all currently defined number
registers on `stderr'.
- Request: .ptr
Prints the names and positions of all traps (not including input
line traps and diversion traps) on `stderr'. Empty slots in the
page trap list are printed as well, because they can affect the
priority of subsequently planted traps.
- Request: .fl
Instructs `gtroff' to flush its output immediately. The intent is
for interactive use. `gtroff'; there is little other use for it.
This request causes a line break.
- Request: .backtrace
The `backtrace' request prints a backtrace of the input stack to
the standard error stream.
`gtroff' has command line options for printing out more warnings
(`-w') and for printing backtraces (`-b') when a warning or an error
occurs. The most verbose level of warnings is `-ww'.
- Request: .warn [flags]
- Register: \n[.warn]
Controls the level of warnings checked for. The FLAGS are the sum
of the numbers associated with each warning that is to be enabled;
all other warnings are disabled. The number associated with each
warning is listed below. For example, `.warn 0' disables all
warnings, and `.warn 1' disables all warnings except that about
missing characters. If an argument is not given, all warnings are
enabled.
The read-only number register `.warn' contains the current warning
level.
* Menu:
* Warnings::
File: groff, Node: Warnings, Prev: Debugging, Up: Debugging
Warnings
--------
The warnings that can be given to `gtroff' are divided into the
following categories. The name associated with each warning is used by
the `-w' and `-W' options; the number is used by the `warn' request and
by the `.warn' register.
`char'
`1'
Non-existent characters. This is enabled by default.
`number'
`2'
Invalid numeric expressions. This is enabled by default. *Note
Expressions::.
`break'
`4'
In fill mode, lines which could not be broken so that their length
was less than the line length. This is enabled by default.
`delim'
`8'
Missing or mismatched closing delimiters.
`el'
`16'
Use of the `el' request with no matching `ie' request. *Note
if-else::.
`scale'
`32'
Meaningless scaling indicators.
`range'
`64'
Out of range arguments.
`syntax'
`128'
Dubious syntax in numeric expressions.
`di'
`256'
Use of `di' or `da' without an argument when there is no current
diversion.
`mac'
`512'
Use of undefined strings, macros and diversions. When an undefined
string, macro or diversion is used, that string is automatically
defined as empty. So, in most cases, at most one warning is given
for each name.
`reg'
`1024'
Use of undefined number registers. When an undefined number
register is used, that register is automatically defined to have a
value of 0. A definition is automatically made with a value of 0.
So, in most cases, at most one warning is given for use of a
particular name.
`tab'
`2048'
Use of a tab character where a number was expected.
`right-brace'
`4096'
Use of `\}' where a number was expected.
`missing'
`8192'
Requests that are missing non-optional arguments.
`input'
`16384'
Illegal input characters.
`escape'
`32768'
Unrecognized escape sequences. When an unrecognized escape
sequence is encountered, the escape character is ignored.
`space'
`65536'
Missing space between a request or macro and its argument. This
warning is given when an undefined name longer than two characters
is encountered, and the first two characters of the name make a
defined name. The request or macro is not invoked. When this
warning is given, no macro is automatically defined. This is
enabled by default. This warning never occurs in compatibility
mode.
`font'
`131072'
Non-existent fonts. This is enabled by default.
`all'
All warnings except `di', `mac' and `reg'. It is intended that
this covers all warnings that are useful with traditional macro
packages.
`w'
All warnings.
File: groff, Node: Implementation Differences, Next: Summary, Prev: Debugging, Up: gtroff Reference
Implementation Differences
==========================
GNU `troff' has a number of features which cause incompatibilities
with documents written with old versions of `troff'.
Long names cause some incompatibilities. UNIX `troff' interprets
.dsabcd
as defining a string `ab' with contents `cd'. Normally, GNU `troff'
interprets this as a call of a macro named `dsabcd'. Also UNIX `troff'
interprets `\*[' or `\n[' as references to a string or number register
called `['. In GNU `troff', however, this is normally interpreted as
the start of a long name. In compatibility mode GNU `troff' interprets
long names in the traditional way (which means that they are not
recognized as names). Compatibility mode can be turned on with the
`-C' command line option, and turned on or off with the `cp' request.
The number register `.C' is 1 if compatibility mode is on, 0 otherwise.
GNU `troff' does not allow the use of the escape sequences `\|',
`\^', `\&', `\{', `\}', `\<SP>', `\'', `\`', `\-', `\_', `\!', `\%',
and `\c' in names of strings, macros, diversions, number registers,
fonts or environments; UNIX `troff' does. The `\A' escape sequence
(*note Identifiers::) may be helpful in avoiding use of these escape
sequences in names.
Fractional point sizes cause one noteworthy incompatibility. In
UNIX `troff' the `ps' request ignores scale indicators and thus
.ps 10u
sets the point size to 10 points, whereas in GNU `troff' it sets the
point size to 10 scaled points. *Note Fractional Type Sizes::, for
more information.
In GNU `troff' there is a fundamental difference between
unformatted, input characters, and formatted, output characters.
Everything that affects how an output character is output is stored
with the character; once an output character has been constructed it is
unaffected by any subsequent requests that are executed, including
`bd', `cs', `tkf', `tr', or `fp' requests. Normally output characters
are constructed from input characters at the moment immediately before
the character is added to the current output line. Macros, diversions
and strings are all, in fact, the same type of object; they contain
lists of input characters and output characters in any combination. An
output character does not behave like an input character for the
purposes of macro processing; it does not inherit any of the special
properties that the input character from which it was constructed might
have had. For example,
.di x
\\\\
.br
.di
.x
prints `\\' in GNU `troff'; each pair of input backslashes is turned
into one output backslash and the resulting output backslashes are not
interpreted as escape characters when they are reread. UNIX `troff'
would interpret them as escape characters when they were reread and
would end up printing one `\'. The correct way to obtain a printable
backslash is to use the `\e' escape sequence: This always prints a
single instance of the current escape character, regardless of whether
or not it is used in a diversion; it also works in both GNU `troff' and
UNIX `troff'. To store, for some reason, an escape sequence in a
diversion that will be interpreted when the diversion is reread, either
use the traditional `\!' transparent output facility, or, if this is
unsuitable, the new `\?' escape sequence.
*Note Diversions::, for more information.
File: groff, Node: Summary, Prev: Implementation Differences, Up: gtroff Reference
Summary
=======
File: groff, Node: Preprocessors, Next: Output Devices, Prev: gtroff Reference, Up: Top
Preprocessors
*************
This chapter describes all preprocessors that come with `groff' or
which are freely available.
* Menu:
* geqn::
* gtbl::
* gpic::
* ggrn::
* grap::
* grefer::
* gsoelim::
File: groff, Node: geqn, Next: gtbl, Prev: Preprocessors, Up: Preprocessors
`geqn'
======
* Menu:
* Invoking geqn::
File: groff, Node: Invoking geqn, Prev: geqn, Up: geqn
Invoking `geqn'
---------------
File: groff, Node: gtbl, Next: gpic, Prev: geqn, Up: Preprocessors
`gtbl'
======
* Menu:
* Invoking gtbl::
File: groff, Node: Invoking gtbl, Prev: gtbl, Up: gtbl
Invoking `gtbl'
---------------
File: groff, Node: gpic, Next: ggrn, Prev: gtbl, Up: Preprocessors
`gpic'
======
* Menu:
* Invoking gpic::
File: groff, Node: Invoking gpic, Prev: gpic, Up: gpic
Invoking `gpic'
---------------
File: groff, Node: ggrn, Next: grap, Prev: gpic, Up: Preprocessors
`ggrn'
======
* Menu:
* Invoking ggrn::
File: groff, Node: Invoking ggrn, Prev: ggrn, Up: ggrn
Invoking `ggrn'
---------------
File: groff, Node: grap, Next: grefer, Prev: ggrn, Up: Preprocessors
`grap'
======
A free implementation of `grap', written by Ted Faber, is available
as an extra package from the following address:
<http://www.lunabase.org/~faber/Vault/software/grap/>
File: groff, Node: grefer, Next: gsoelim, Prev: grap, Up: Preprocessors
`grefer'
========
* Menu:
* Invoking grefer::
File: groff, Node: Invoking grefer, Prev: grefer, Up: grefer
Invoking `grefer'
-----------------
File: groff, Node: gsoelim, Prev: grefer, Up: Preprocessors
`gsoelim'
=========
* Menu:
* Invoking gsoelim::
File: groff, Node: Invoking gsoelim, Prev: gsoelim, Up: gsoelim
Invoking `gsoelim'
------------------
File: groff, Node: Output Devices, Next: File formats, Prev: Preprocessors, Up: Top
Output Devices
**************
* Menu:
* Special Characters::
* grotty::
* grops::
* grodvi::
* grolj4::
* grolbp::
* grohtml::
* gxditview::
File: groff, Node: Special Characters, Next: grotty, Prev: Output Devices, Up: Output Devices
Special Characters
==================
*Note Font Files::.
File: groff, Node: grotty, Next: grops, Prev: Special Characters, Up: Output Devices
`grotty'
========
* Menu:
* Invoking grotty::
File: groff, Node: Invoking grotty, Prev: grotty, Up: grotty
Invoking `grotty'
-----------------
File: groff, Node: grops, Next: grodvi, Prev: grotty, Up: Output Devices
`grops'
=======
* Menu:
* Invoking grops::
* Embedding PostScript::
File: groff, Node: Invoking grops, Next: Embedding PostScript, Prev: grops, Up: grops
Invoking `grops'
----------------
File: groff, Node: Embedding PostScript, Prev: Invoking grops, Up: grops
Embedding POSTSCRIPT
--------------------
File: groff, Node: grodvi, Next: grolj4, Prev: grops, Up: Output Devices
`grodvi'
========
* Menu:
* Invoking grodvi::
File: groff, Node: Invoking grodvi, Prev: grodvi, Up: grodvi
Invoking `grodvi'
-----------------
File: groff, Node: grolj4, Next: grolbp, Prev: grodvi, Up: Output Devices
`grolj4'
========
* Menu:
* Invoking grolj4::
File: groff, Node: Invoking grolj4, Prev: grolj4, Up: grolj4
Invoking `grolj4'
-----------------
File: groff, Node: grolbp, Next: grohtml, Prev: grolj4, Up: Output Devices
`grolbp'
========
* Menu:
* Invoking grolbp::
File: groff, Node: Invoking grolbp, Prev: grolbp, Up: grolbp
Invoking `grolbp'
-----------------
File: groff, Node: grohtml, Next: gxditview, Prev: grolbp, Up: Output Devices
`grohtml'
=========
* Menu:
* Invoking grohtml::
File: groff, Node: Invoking grohtml, Prev: grohtml, Up: grohtml
Invoking `grohtml'
------------------
File: groff, Node: gxditview, Prev: grohtml, Up: Output Devices
`gxditview'
===========
* Menu:
* Invoking gxditview::
File: groff, Node: Invoking gxditview, Prev: gxditview, Up: gxditview
Invoking `gxditview'
--------------------
File: groff, Node: File formats, Next: Installation, Prev: Output Devices, Up: Top
File formats
************
* Menu:
* gtroff Output::
* Font Files::
File: groff, Node: gtroff Output, Next: Font Files, Prev: File formats, Up: File formats
`gtroff' Output
===============
This section describes the format output of GNU `troff'. The output
format used by GNU `troff' is very similar - but not identical - to
that used by UNIX device-independent `troff' (`ditroff').
* Menu:
* Output Format::
* Device Control::
* Drawing Functions::
* Line Continuation::